<template>
  <el-dialog
    class="close-dialog"
    :title="dialog.title"
    width="900px"
    :visible.sync="dialog.visible"
    :append-to-body="true"
    @close="cancle"
  >
    <div class="main">
      <el-table
        :data="roleList"
        highlight-current-row
        @current-change="handleCurrentChange"
        height="500px"
      >
        <el-table-column prop="deptName" label="部门名称"></el-table-column>
        <el-table-column prop="orderNum" label="排序"></el-table-column>
        <el-table-column prop="status" label="状态">
          <template slot-scope="scope">
            <dict-tag
              :options="dict.type.sys_normal_disable"
              :value="scope.row.status"
            />
          </template>
        </el-table-column>
        <el-table-column label="创建时间" align="center" prop="createTime">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.createTime) }}</span>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="foot">
      <el-button @click="submit" type="primary">确定</el-button>
      <el-button @click="cancle">取消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { listDept } from "@/api/system/dept";
export default {
  dicts: ["sys_normal_disable"],
  data() {
    return {
      dialog: {
        visible: false,
        title: "服务团队 ",
      },
      roleList: [],
      queryParams: {},
      currentRow: null,
    };
  },
  methods: {
    //打开弹窗
    async open() {
      listDept(this.queryParams).then((response) => {
        console.log(response);
        this.roleList = response.data.filter((item) => {
          return item.ancestors.split(",").length == 2;
        });
      });

      this.currentRow = null;
      this.dialog.visible = true;
    },
    handleCurrentChange(val) {
      console.log(val);
      this.currentRow = val;
    },
    //确定
    submit() {
      this.$emit("submit", this.currentRow);
      this.dialog.visible = false;
    },
    cancle() {
      this.dialog.visible = false;
    },
  },
};
</script>

<style scoped lang="scss">
.close-dialog {
  .foot {
    text-align: center;
    margin-top: 20px;
  }
}
::v-deep .el-dialog .el-dialog__body {
  display: flex;
  justify-content: space-between;
  flex-direction: column;
  height: auto;
  padding-bottom: 40px;
}
</style>
